from odoo import api, models, fields
from odoo.exceptions import ValidationError

class SaleAdvancePaymentInv(models.TransientModel):
    _inherit = 'sale.advance.payment.inv'

    def create_invoices(self):
        for sale in self.sale_order_ids:
            if sale.is_lock:
                raise ValidationError('Sale order is lock, please unlock')


